<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('快速备课班级列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>班级名：</label>
                            <input type="text" name="className"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var prefix = ctx + "teaching/prepare";
    var class_status = [[${@dict.getType('sys_classes_status')}]];

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "快速备课",
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            columns: [{
                checkbox: true
            },
                {
                    field: 'classId',
                    title: '主键ID',
                    visible: false
                },
                {
                    field: 'className',
                    title: '班级名',
                    formatter: function (value, row, index) {
                        return '<a href="javascript:void(0)" onclick="detail(\'' + row.classId + '\')">' + value + '</a>';
                    }
                },
                {
                    field: 'teacherName',
                    title: '上课老师',
                    visible: false
                },
                {
                    field: 'courseName',
                    title: '课程'
                },
                {
                    field: 'schoolName',
                    title: '所属校区'
                },
                {
                    field: 'lessonStatus',
                    title: '开课状态',
                    formatter: function (value, row, index) {
                        return value == "0" ? "未开课" : "<font style='color:red'>上课中</font>";
                    }

                },
                // {
                //     field: 'classStudent',
                //     title: '在读人数'
                // },
                {
                    // field: 'maxStudent',
                    title: '人数',
                    formatter: function (value, row, index) {
                        return row.classStudent + '/' + row.maxStudent;
                    }
                },
                // {
                //     field: 'classroomName',
                //     title: '教室'
                // },
                {
                    field: 'teachTime',
                    title: '上课时间',
                    visible: false
                },
                {
                    field: 'status',
                    title: '招生状态',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(class_status, value);
                    },
                    visible: false
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="detail(\'' + row.classId + '\')"><i class="fa fa-edit"></i>备课</a> ');
                        actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="preLesson(\'' + row.classId + '\',\'' + row.className + '\')"><i class="fa fa-edit"></i>上课</a> ');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    /*班级-详细*/
    function detail(classId) {
        var url = prefix + '/detail/' + classId;
        $.modal.openTab("备课详情", url);
    }

    /*班级-准备上课*/
    function preLesson(classId, className) {
        // var url = prefix + "/lessonStatus/" + classId;
        url = prefix + '/preLesson/' + classId;
        $.modal.openTab(className, url);
        // $.operate.post(url, null, function (result) {
        //     if (result.code == 500) {
        //         //正在上课
        //         $.modal.msgError("此班级正在上课");
        //         return false;
        //     } else {
        //
        //     }
        // })

    }
</script>
</body>
</html>
